package com.compty.paint.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.compty.security.domain.User;

/**
 * @Todo:文章
 * @author: zhuqh
 * @CreateTime:2011-9-15 下午05:56:49
 */
@Entity
@Table(name = "t_article")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Article implements Serializable{

	private static final long serialVersionUID = 8288227239962167572L;
	
	private Long id;
	
	/************ 主题 ****************/
	private String title;
	
	/************ 文章来源 ****************/
	private String original;
	
	/************ 文章内容 ****************/
	private String htmlContent;
	
	/************ 广告图片 ****************/
	private List<ImageInfo> imageInfoList;
	
	/************ 审核状态 ****************/
	private AuditState auditState;
	
	/************ 上传时间 ****************/
	private Date uploadTime;
	
	/************ 最后修改时间  ****************/
	private Date modifyTime;
	
	/************ 录入人  ****************/
	private User entryPerson;
	
	/************ 修改人  ****************/
	private User modifyPerson;
	
	@Id
	@GeneratedValue
	@Column(name = "id", unique = true, nullable = false)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "title", length = 100)
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Basic(fetch = FetchType.LAZY)
	@Column(name = "htmlcontent")
	public String getHtmlContent() {
		return htmlContent;
	}

	public void setHtmlContent(String htmlContent) {
		this.htmlContent = htmlContent;
	}

	@ManyToMany(cascade =  {CascadeType.REMOVE}, fetch = FetchType.LAZY)
	    @JoinTable(name = "t_article_image", joinColumns =  {
	        @JoinColumn(name = "article_id")
	    }
	    , inverseJoinColumns =  {
	        @JoinColumn(name = "image_id")
	    }
	  )
	public List<ImageInfo> getImageInfoList() {
		return imageInfoList;
	}

	public void setImageInfoList(List<ImageInfo> imageInfoList) {
		this.imageInfoList = imageInfoList;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "auditstate_id")
	public AuditState getAuditState() {
		return auditState;
	}

	public void setAuditState(AuditState auditState) {
		this.auditState = auditState;
	}

	@Column(name = "uploadtime")
	public Date getUploadTime() {
		return uploadTime;
	}

	public void setUploadTime(Date uploadTime) {
		this.uploadTime = uploadTime;
	}

	@Column(name = "modifytime")
	public Date getModifyTime() {
		return modifyTime;
	}

	public void setModifyTime(Date modifyTime) {
		this.modifyTime = modifyTime;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="userinfo_id")
	public User getEntryPerson() {
		return entryPerson;
	}

	public void setEntryPerson(User entryPerson) {
		this.entryPerson = entryPerson;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="modify_userinfo_id")
	public User getModifyPerson() {
		return modifyPerson;
	}

	public void setModifyPerson(User modifyPerson) {
		this.modifyPerson = modifyPerson;
	}
	
	@Column(name = "original", length = 100)
	public String getOriginal() {
		return original;
	}

	public void setOriginal(String original) {
		this.original = original;
	}
	
}
